Learn R Programming

NMF (version 0.5.06)

NMF dimensions: Dimension names for NMF objects

Description

The methods dimnames, rownames, colnames and basisnames and their respective replacement form allow to get and set the dimension names of the matrix factors in a NMF model.

They behave as their equivalent on matrix objects, and ensure that the dimension names are handled in a consistent way on both factors -- especially basisnames<- which affects both matrix factors simultaneously.

The methods dimnames and basisnames are implemented as S4 methods, while the methods rownames and colnames are the default ones that make use of the result from dimnames.

Usage

## S3 method for class 'NMF':
basisnames(x)
## S3 method for class 'NMF':
basisnames(x, \dots) <- value

## S3 method for class 'NMF': dimnames(x) ## S3 method for class 'NMF': dimnames(x) <- value

Arguments

x
an object of class NMF.
value
a character vector, or NULL or, in the case of dimnames<-, a list 2 or 3-length list of character vectors. See section Details for more details.
...
extra argument to pass to internal methods. Not used.

Details

[object Object],[object Object],[object Object],[object Object],[object Object]

Examples

Run this code
# create a random NMF object
a <- nmfModel(3, 10, 5)
a <- rnmf(a)

# set dimensions
dims <- list( features=paste('f', 1:nrow(a), sep=''), samples=paste('s', 1:ncol(a), sep=''), basis=paste('b', 1:nbasis(a), sep='') )
dimnames(a) <- dims
dimnames(a)
basis(a)
coef(a)

# access the dimensions separately
rownames(a)
colnames(a)
basisnames(a)

# set only the two first dimensions (rows and columns of basis and coef respectively)
dimnames(a) <- dims[1:2]
dimnames(a)
basis(a)

# set each dimensions separately
rownames(a) <- paste('X', 1:nrow(a), sep='') # only affect rows of basis
basis(a)

colnames(a) <- paste('Y', 1:ncol(a), sep='') # only affect columns of coef
coef(a)

basisnames(a) <- paste('Z', 1:nbasis(a), sep='') # affect both basis and coef matrices
basis(a)
coef(a)

Run the code above in your browser using DataLab